package test.oldcase;

import java.sql.Connection;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.sql.DataSource;

import org.junit.Test;

import test.pojo.Users;

import com.javabloger.orm.IObjectDaos;
import com.javabloger.orm.PersistenceManager;
import com.javabloger.orm.SimpleDataSource;

public class ServiceTestCase {

			String dirver="com.mysql.jdbc.Driver" ;
			String url="jdbc:mysql://127.0.0.1/smbcrm";
			String username="root";
			String password="123456";
			
			IObjectDaos  uu= new PersistenceManager();

			 
			 @Test
				public void queryService () throws  Exception{
				 
				 DataSource  dataSource= new SimpleDataSource(
						 dirver, url,
						 username, password) ;
				 
//				 Connection connection=dataSource.getConnection(); uu.setConnection(connection);
			
				 uu.setDataSource(dataSource);
				 
				 uu.startTransaction();
				 Map<?, ?> map= uu.queryMap(  " show  status  like 'uptime' " ) ;
				 System.out.println (map );
				 
				List list= uu.queryList("select * from crm_users", Users.class); 
				 System.out.println (list );
				 
				 uu.endTransaction();
			 
			 }
			 
			 
			 @Test
				public void addService () throws  Exception{
				 DataSource  dataSource= new SimpleDataSource(
						 dirver, url,
						 username, password) ;
				 uu.setDataSource(dataSource);
				 
				 Users user= new Users();
				 
				 uu.startTransaction();
				 user.setDept("111");
				 user.setEmail( "1email11");
				 user.setPassword( "password1email11");
				 uu.addObject(  user) ;
				 
				 Users user1= new Users();
				 uu.addObject(  user1) ;
				 uu.endTransaction();
			 }
				 
			
			
}
